﻿using System;
using System.Collections.Generic;
using System.Windows.Forms;
using TestContentTool.TestControls;

namespace TestContentTool
{
    public partial class TestContentForm : Form
    {
        private Dictionary<string, IIdentifiableTestControl> testControls = new Dictionary<string, IIdentifiableTestControl>();

        public TestContentForm()
        {
            InitializeComponent();
        }


        private void refreshToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (testsListView.SelectedItems.Count <= 0)
                return;

            testsListView.SelectedItems[0].Text = testControls[testsListView.SelectedItems[0].ImageKey].Display;
        }

        private void removeToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (testsListView.SelectedItems.Count <= 0)
                return;

            var identifiable = testControls[testsListView.SelectedItems[0].ImageKey];
            splitContainer.Panel2.Controls.Remove((Control)identifiable);
            testControls.Remove(identifiable.Id);
            testsListView.Items.Remove(testsListView.SelectedItems[0]);
        }

        private void addCheckTestToolStripMenuItem_Click(object sender, EventArgs e)
        {
            var control = TestControlsFactory.GetCheckTestControl();
            splitContainer.Panel2.Controls.Add(control);
            testsListView.Items.Add(control.Display, control.Id);
            testControls.Add(control.Id, control);
        }
        private void addRadioTestToolStripMenuItem_Click(object sender, EventArgs e)
        {
            var control = TestControlsFactory.GetRadioTestControl();
            splitContainer.Panel2.Controls.Add(control);
            testsListView.Items.Add(control.Display, control.Id);
            testControls.Add(control.Id, control);
        }
        private void addInputTestToolStripMenuItem_Click(object sender, EventArgs e)
        {
            var control = TestControlsFactory.GetInputTestControl();
            splitContainer.Panel2.Controls.Add(control);
            testsListView.Items.Add(control.Display, control.Id);
            testControls.Add(control.Id, control);
        }

        private void saveToolStripMenuItem_Click(object sender, EventArgs e)
        {

        }

        private void exitToolStripMenuItem_Click(object sender, EventArgs e)
        {
            Close();
        }
    }
}
